/**
 * 圆形
 * ibio-develop
 * 2008-11-22 17:42
 */
package com.ibio8.components.wave.behavior {
	import com.ibio8.components.wave.WaveBody;
	
	import flash.utils.ByteArray;

	public class Circle implements IWaveBehavior {
		
		public function show(ba:ByteArray, sp:WaveBody):void {
			//半径，使半径始终等于最长边
			var l:Number = sp.h;
			if (sp.w > sp.h) {
				l = sp.w;
			}
			var radius:Number =  -ba.readFloat() * l + l/10;
			var temp:Number = radius;
			var dispX:Number, dispY:Number;
			dispX = sp.w / 2;
			dispY = sp.h / 2;
			//完整的一圈
			var angStep:Number = 2 * Math.PI / 512;
			sp.graphics.moveTo(radius * Math.sin(0) + dispX, radius * Math.cos(0) + dispY);
			for (var i:Number = 1; i < 512; i++) {
				
				radius = -ba.readFloat() * l + l/10;
				sp.graphics.lineTo(radius * Math.sin(i * angStep) + dispX, radius * Math.cos(i * angStep) + dispY);
			}
			sp.graphics.lineTo(temp * Math.sin(0) + dispX, temp * Math.cos(0) + dispY);
		}
	}
}